package com.lxz.aimedicalassistantbackend.config;

import com.lxz.aimedicalassistantbackend.store.ChatMemoryStore;
import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.memory.chat.MessageWindowChatMemory;

import jakarta.annotation.Resource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: 小新
 * @Date: 2025/4/25 18:53
 * @Description: 聊天记忆配置类
 * @Version: v1.0
 */
@Configuration
public class MemoryChatProviderAssistantConfig {

    @Resource
    private ChatMemoryStore chatMemoryStore;

    @Bean
    ChatMemoryProvider chatMemoryProvider() {
        return memoryId -> MessageWindowChatMemory
                .builder()
                .id(memoryId)
                .maxMessages(10)
                .chatMemoryStore(chatMemoryStore)
                .build();
    }
}
